﻿using System;
using System.Data;
using System.Data.SqlClient;
using System.Windows.Forms;

namespace Texpro
{
    public partial class FMMN103 : Form
    {

        SqlConnection sql_conn = new SqlConnection();
        SqlCommand sql_comm = new SqlCommand();
        SqlDataAdapter sql_adap = new SqlDataAdapter();
        DataTable dt_list = new DataTable();

        public FMMN103()
        {
            InitializeComponent();
        }

        // events

        private void FMMN103_Load(object sender, EventArgs e)
        {
            //this.WindowState = FormWindowState.Maximized;
            set_form_size();
            this.Tag = PCPUB.m_form_id;
            switch (this.Tag.ToString())
            {
                case "FMTR101":
                    load_FMTR101();
                    break;
                case "FMTR102":
                    load_FMTR102();
                    break;
                case "FMTR103":
                    load_FMTR103();
                    break;
                case "FMTR201":
                    load_FMTR201();
                    break;
                case "FMTR202":
                    load_FMTR202();
                    break;
                case "FMTR301":
                    load_FMTR301();
                    break;
                case "FMTR302":
                    load_FMTR302();
                    break;
                case "FMTR303":
                    load_FMTR303();
                    break;
                case "FMTR401":
                    load_FMTR401();
                    break;
                case "FMTR402":
                    load_FMTR402();
                    break;
                case "FMTR501":
                    load_FMTR501();
                    break;
                case "FMTR502":
                    load_FMTR502();
                    break;
                case "FMTR601":
                    load_FMTR601();
                    break;
                case "FMTR602":
                    load_FMTR602();
                    break;
                case "FMTR603":
                    load_FMTR603();
                    break;
                case "FMAD101":
                    load_FMAD101();
                    break;
                case "FMAD102":
                    load_FMAD102();
                    break;
                case "FMAD103":
                    load_FMAD103();
                    break;
                case "FMAD104":
                    load_FMAD104();
                    break;
                case "FMAD106":
                    load_FMAD106();
                    break;
                case "FMAD107":
                    load_FMAD107();
                    break;
                case "FMAD108":
                    load_FMAD108();
                    break;
                case "FMAD109":
                    load_FMAD109();
                    break;
            }
            this.sc_main_list.SplitterDistance = 300;
            // UseWaitCursor = false;
        }

        private void FMMN103_FormClosed(object sender, FormClosedEventArgs e)
        {
            switch (this.Tag.ToString())
            {
                case "FMTR101":
                    PCPUB.m_FMTR101_open = false;
                    break;
                case "FMTR102":
                    PCPUB.m_FMTR102_open = false;
                    break;
                case "FMTR103":
                    PCPUB.m_FMTR103_open = false;
                    break;
                case "FMTR201":
                    PCPUB.m_FMTR201_open = false;
                    break;
                case "FMTR202":
                    PCPUB.m_FMTR202_open = false;
                    break;
                case "FMTR301":
                    PCPUB.m_FMTR301_open = false;
                    break;
                case "FMTR302":
                    PCPUB.m_FMTR302_open = false;
                    break;
                case "FMTR303":
                    PCPUB.m_FMTR303_open = false;
                    break;
                case "FMTR401":
                    PCPUB.m_FMTR401_open = false;
                    break;
                case "FMTR402":
                    PCPUB.m_FMTR402_open = false;
                    break;
                case "FMTR501":
                    PCPUB.m_FMTR501_open = false;
                    break;
                case "FMTR502":
                    PCPUB.m_FMTR502_open = false;
                    break;
                case "FMTR601":
                    PCPUB.m_FMTR601_open = false;
                    break;
                case "FMTR602":
                    PCPUB.m_FMTR602_open = false;
                    break;
                case "FMTR603":
                    PCPUB.m_FMTR603_open = false;
                    break;
                case "FMAD101":
                    PCPUB.m_FMAD101_open = false;
                    break;
                case "FMAD102":
                    PCPUB.m_FMAD102_open = false;
                    break;
                case "FMAD103":
                    PCPUB.m_FMAD103_open = false;
                    break;
                case "FMAD104":
                    PCPUB.m_FMAD104_open = false;
                    break;
                case "FMAD105":
                    PCPUB.m_FMAD105_open = false;
                    break;
                case "FMAD106":
                    PCPUB.m_FMAD106_open = false;
                    break;
                case "FMAD107":
                    PCPUB.m_FMAD107_open = false;
                    break;
                case "FMAD108":
                    PCPUB.m_FMAD108_open = false;
                    break;
                case "FMAD109":
                    PCPUB.m_FMAD109_open = false;
                    break;
            }

        }

        private void tsb_refresh_Click(object sender, EventArgs e)
        {
            PCPUB.m_record_id = string.Empty;
            tsb_delete.Enabled = false;
            tsb_print.Enabled = false;
            tsb_edit.Enabled = false;
            dt_list.Clear();
            sql_adap.Fill(dt_list);
        }

        private void tsb_addnew_Click(object sender, EventArgs e)
        {
            if (this.Tag.ToString().Equals("FMTR603"))
            {
                if (PCPUB.m_tran_date.DayOfWeek.ToString().Equals("Friday"))
                {
                    PCPUB.m_entry_form_mode = "ADDNEW";
                    load_child_form(this.Tag.ToString());
                    tsb_refresh_Click(sender, e);
                }
                else
                {
                    PCMSG.ShowError("Payment voucher creation is permitted only on 'Friday'. Please change date to 'Friday' and proceed.");
                }
            }
            else
            {
                PCPUB.m_entry_form_mode = "ADDNEW";
                load_child_form(this.Tag.ToString());
                tsb_refresh_Click(sender, e);
            }
        }

        private void tsb_edit_Click(object sender, EventArgs e)
        {
            PCPUB.m_entry_form_mode = "EDIT";
            load_child_form(this.Tag.ToString());
            tsb_refresh_Click(sender, e);  
        }

        private void tsb_delete_Click(object sender, EventArgs e)
        {
            DialogResult dr;
            bool delete_status = false;
            if (PCPUB.m_record_id.Length > 0)
            {
                dr = PCMSG.Show("Do you want to delete selected record?", "Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);
                if (dr == DialogResult.Yes)
                {
                    switch (this.Tag.ToString())
                    {
                        case "FMTR101":
                            PCPUB.m_record_date = PCPUB.m_record_date.Substring(6, 4) + "-" + PCPUB.m_record_date.Substring(3, 2) + "-" + PCPUB.m_record_date.Substring(0, 2);
                            delete_status = PCDB.delete_tis_yarn_purchase_iw(PCPUB.m_record_id.ToString(), PCPUB.m_record_date.ToString());
                            break;
                        case "FMTR102":
                            PCPUB.m_record_date = PCPUB.m_record_date.Substring(6, 4) + "-" + PCPUB.m_record_date.Substring(3, 2) + "-" + PCPUB.m_record_date.Substring(0, 2);
                            delete_status = PCDB.delete_tis_yarn_sales_ow(PCPUB.m_record_id.ToString(), PCPUB.m_record_date.ToString());
                            break;
                        case "FMTR103":
                            PCPUB.m_record_date = PCPUB.m_record_date.Substring(6, 4) + "-" + PCPUB.m_record_date.Substring(3, 2) + "-" + PCPUB.m_record_date.Substring(0, 2);
                            delete_status = PCDB.delete_tis_yarn_material_iw(PCPUB.m_record_id.ToString(), PCPUB.m_record_date.ToString());
                            break;
                        case "FMTR201":
                            PCPUB.m_record_date = PCPUB.m_record_date.Substring(6, 4) + "-" + PCPUB.m_record_date.Substring(3, 2) + "-" + PCPUB.m_record_date.Substring(0, 2);
                            delete_status = PCDB.delete_tis_dyeing_ow(PCPUB.m_record_id.ToString(), PCPUB.m_record_date.ToString());
                            break;
                        case "FMTR202":
                            PCPUB.m_record_date = PCPUB.m_record_date.Substring(6, 4) + "-" + PCPUB.m_record_date.Substring(3, 2) + "-" + PCPUB.m_record_date.Substring(0, 2);
                            delete_status = PCDB.delete_tis_dyeing_iw(PCPUB.m_record_id.ToString(), PCPUB.m_record_date.ToString());
                            break;
                        case "FMTR301":
                            PCPUB.m_record_date = PCPUB.m_record_date.Substring(6, 4) + "-" + PCPUB.m_record_date.Substring(3, 2) + "-" + PCPUB.m_record_date.Substring(0, 2);
                            delete_status = PCDB.delete_tis_weaving_ow(PCPUB.m_record_id.ToString(), PCPUB.m_record_date.ToString());
                            break;
                        case "FMTR302":
                            PCPUB.m_record_date = PCPUB.m_record_date.Substring(6, 4) + "-" + PCPUB.m_record_date.Substring(3, 2) + "-" + PCPUB.m_record_date.Substring(0, 2);
                            delete_status = PCDB.delete_tis_weaving_iw(PCPUB.m_record_id.ToString(), PCPUB.m_record_date.ToString());
                            break;
                        case "FMTR303":
                            PCPUB.m_record_date = PCPUB.m_record_date.Substring(6, 4) + "-" + PCPUB.m_record_date.Substring(3, 2) + "-" + PCPUB.m_record_date.Substring(0, 2);
                            delete_status = PCDB.delete_tis_weaving_adj(PCPUB.m_record_id.ToString(), PCPUB.m_record_date.ToString());
                            break;
                        case "FMTR401":
                            PCPUB.m_record_date = PCPUB.m_record_date.Substring(6, 4) + "-" + PCPUB.m_record_date.Substring(3, 2) + "-" + PCPUB.m_record_date.Substring(0, 2);
                            delete_status = PCDB.delete_tis_washing_ow(PCPUB.m_record_id.ToString(), PCPUB.m_record_date.ToString());
                            break;
                        case "FMTR402":
                            PCPUB.m_record_date = PCPUB.m_record_date.Substring(6, 4) + "-" + PCPUB.m_record_date.Substring(3, 2) + "-" + PCPUB.m_record_date.Substring(0, 2);
                            delete_status = PCDB.delete_tis_washing_iw(PCPUB.m_record_id.ToString(), PCPUB.m_record_date.ToString());
                            break;
                        case "FMTR501":
                            PCPUB.m_record_date = PCPUB.m_record_date.Substring(6, 4) + "-" + PCPUB.m_record_date.Substring(3, 2) + "-" + PCPUB.m_record_date.Substring(0, 2);
                            delete_status = PCDB.delete_tis_tailoring_ow(PCPUB.m_record_id.ToString(), PCPUB.m_record_date.ToString());
                            break;
                        case "FMTR502":
                            PCPUB.m_record_date = PCPUB.m_record_date.Substring(6, 4) + "-" + PCPUB.m_record_date.Substring(3, 2) + "-" + PCPUB.m_record_date.Substring(0, 2);
                            delete_status = PCDB.delete_tis_tailoring_iw(PCPUB.m_record_id.ToString(), PCPUB.m_record_date.ToString());
                            break;
                        case "FMTR601":
                            //PCPUB.m_record_date = PCPUB.m_record_date.Substring(6, 4) + "-" + PCPUB.m_record_date.Substring(3, 2) + "-" + PCPUB.m_record_date.Substring(0, 2);
                            //delete_status = PCDB.delete_tis_payment(PCPUB.m_record_id.ToString(), PCPUB.m_record_date.ToString());
                            break;
                        case "FMTR602":
                            PCPUB.m_record_date = PCPUB.m_record_date.Substring(6, 4) + "-" + PCPUB.m_record_date.Substring(3, 2) + "-" + PCPUB.m_record_date.Substring(0, 2);
                            delete_status = PCDB.delete_tis_receipt(PCPUB.m_record_id.ToString(), PCPUB.m_record_date.ToString());
                            break;
                        case "FMTR603":
                            PCPUB.m_record_date = PCPUB.m_record_date.Substring(6, 4) + "-" + PCPUB.m_record_date.Substring(3, 2) + "-" + PCPUB.m_record_date.Substring(0, 2);
                            if (PCPUB.m_record_status.Equals("Created"))
                            {
                                delete_status = PCDB.delete_tis_payment(PCPUB.m_record_id.ToString(), PCPUB.m_record_date.ToString());
                            }
                            else
                            {
                                dr = PCMSG.Show("Payment already made and record status is 'Paid'. Record cannot be deleted.", "Delete", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
                            }    
                            break;
                        case "FMAD101":
                            delete_status = PCDB.delete_tis_user(PCPUB.m_record_id.ToString());
                            break;
                        case "FMAD102":
                            delete_status = PCDB.delete_tis_vendor(PCPUB.m_record_id.ToString());
                            break;
                        case "FMAD103":
                            delete_status = PCDB.delete_tis_color(PCPUB.m_record_id.ToString());
                            break;
                        case "FMAD104":
                            delete_status = PCDB.delete_tis_yarn_count(PCPUB.m_record_id.ToString());
                            break;
                        case "FMAD106":
                            delete_status = PCDB.delete_tis_design(PCPUB.m_record_id.ToString());
                            break;
                        case "FMAD107":
                            delete_status = PCDB.delete_tis_size(PCPUB.m_record_id.ToString());
                            break;
                        case "FMAD108":
                            delete_status = PCDB.delete_tis_yarn_name(PCPUB.m_record_id.ToString());
                            break;
                        case "FMAD109":
                            delete_status = PCDB.delete_tis_city(PCPUB.m_record_id.ToString());
                            break;
                    }
                    if (delete_status)
                    {
                        PCMSG.Show("Record deleted successfully.", "Delete", MessageBoxIcon.Information);
                    }
                    else
                    {
                        PCMSG.Show("Record deletion failed.", "Delete", MessageBoxIcon.Error);
                    }
                }
            }
            tsb_refresh_Click(sender, e);
        }

        private void tsb_print_Click(object sender, EventArgs e)
        {
            this.UseWaitCursor = true;
            bool b_status = false;
            switch (this.Tag.ToString())
            {
                case "FMTR101":
                    b_status = PCREP.open_RPTR101();
                    break;
                case "FMTR102":
                    b_status = PCREP.open_RPTR111();
                    break;
                case "FMTR103":
                    b_status = PCREP.open_RPTR121();
                    break;
                case "FMTR201":
                    b_status = PCREP.open_RPTR201();
                    break;
                case "FMTR202":
                    b_status = PCREP.open_RPTR211();
                    break;
                case "FMTR301":
                    b_status = PCREP.open_RPTR301();
                    break;
                case "FMTR302":
                    b_status = PCREP.open_RPTR311();
                    break;
                case "FMTR303":
                    b_status = PCREP.open_RPTR321();
                    break;
                case "FMTR401":
                    b_status = PCREP.open_RPTR401();
                    break;
                case "FMTR402":
                    b_status = PCREP.open_RPTR411();
                    break;
                case "FMTR501":
                    b_status = PCREP.open_RPTR501();
                    break;
                case "FMTR502":
                    b_status = PCREP.open_RPTR511();
                    break;
                case "FMTR601":
                    b_status = PCREP.open_RPTR601();
                    break;
                case "FMTR602":
                    b_status = PCREP.open_RPTR602();
                    break;
                case "FMTR603":
                    b_status = PCREP.open_RPTR603();
                    break;
            }
            this.UseWaitCursor = false;
            if (b_status == false)
            {
                PCMSG.Show("Printing request failed.", "Print", MessageBoxIcon.Error);
            }
        }

        private void tsb_close_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void dgv_list_RowEnter(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                dgv_detail.Rows.Clear();
                tsb_edit.Enabled = false;
                tsb_delete.Enabled = false;
                tsb_print.Enabled = false;
                PCPUB.m_record_id = String.Empty;
                PCPUB.m_record_date = String.Empty;
                PCPUB.m_record_status = String.Empty;
                //
                switch (this.Tag.ToString())
                {
                    case "FMTR101":
                        PCPUB.m_record_date = dgv_list[0, e.RowIndex].Value.ToString().Trim();
                        PCPUB.m_record_id = dgv_list[1, e.RowIndex].Value.ToString().Trim();
                        break;
                    case "FMTR102":
                        PCPUB.m_record_date = dgv_list[0, e.RowIndex].Value.ToString().Trim();
                        PCPUB.m_record_id = dgv_list[1, e.RowIndex].Value.ToString().Trim();
                        break;
                    case "FMTR103":
                        PCPUB.m_record_date = dgv_list[0, e.RowIndex].Value.ToString().Trim();
                        PCPUB.m_record_id = dgv_list[1, e.RowIndex].Value.ToString().Trim();
                        break;
                    case "FMTR201":
                        PCPUB.m_record_date = dgv_list[0, e.RowIndex].Value.ToString().Trim();
                        PCPUB.m_record_id = dgv_list[1, e.RowIndex].Value.ToString().Trim();
                        break;
                    case "FMTR202":
                        PCPUB.m_record_date = dgv_list[0, e.RowIndex].Value.ToString().Trim();
                        PCPUB.m_record_id = dgv_list[1, e.RowIndex].Value.ToString().Trim();
                        break;
                    case "FMTR301":
                        PCPUB.m_record_date = dgv_list[0, e.RowIndex].Value.ToString().Trim();
                        PCPUB.m_record_id = dgv_list[1, e.RowIndex].Value.ToString().Trim();
                        break;
                    case "FMTR302":
                        PCPUB.m_record_date = dgv_list[0, e.RowIndex].Value.ToString().Trim();
                        PCPUB.m_record_id = dgv_list[1, e.RowIndex].Value.ToString().Trim();
                        break;
                    case "FMTR303":
                        PCPUB.m_record_date = dgv_list[0, e.RowIndex].Value.ToString().Trim();
                        PCPUB.m_record_id = dgv_list[1, e.RowIndex].Value.ToString().Trim();
                        break;
                    case "FMTR401":
                        PCPUB.m_record_date = dgv_list[0, e.RowIndex].Value.ToString().Trim();
                        PCPUB.m_record_id = dgv_list[1, e.RowIndex].Value.ToString().Trim();
                        break;
                    case "FMTR402":
                        PCPUB.m_record_date = dgv_list[0, e.RowIndex].Value.ToString().Trim();
                        PCPUB.m_record_id = dgv_list[1, e.RowIndex].Value.ToString().Trim();
                        break;
                    case "FMTR501":
                        PCPUB.m_record_date = dgv_list[0, e.RowIndex].Value.ToString().Trim();
                        PCPUB.m_record_id = dgv_list[1, e.RowIndex].Value.ToString().Trim();
                        break;
                    case "FMTR502":
                        PCPUB.m_record_date = dgv_list[0, e.RowIndex].Value.ToString().Trim();
                        PCPUB.m_record_id = dgv_list[1, e.RowIndex].Value.ToString().Trim();
                        break;
                    case "FMTR601":
                        PCPUB.m_record_date = dgv_list[0, e.RowIndex].Value.ToString().Trim();
                        PCPUB.m_record_id = dgv_list[1, e.RowIndex].Value.ToString().Trim();
                        break;
                    case "FMTR602":
                        PCPUB.m_record_date = dgv_list[0, e.RowIndex].Value.ToString().Trim();
                        PCPUB.m_record_id = dgv_list[1, e.RowIndex].Value.ToString().Trim();
                        break;
                    case "FMTR603":
                        PCPUB.m_record_date = dgv_list[0, e.RowIndex].Value.ToString().Trim();
                        PCPUB.m_record_id = dgv_list[1, e.RowIndex].Value.ToString().Trim();
                        PCPUB.m_record_status = dgv_list[6, e.RowIndex].Value.ToString().Trim();
                        break;
                    case "FMAD101":
                        PCPUB.m_record_id = dgv_list[0, e.RowIndex].Value.ToString().Trim();
                        break;
                    case "FMAD102":
                        PCPUB.m_record_id = dgv_list[0, e.RowIndex].Value.ToString().Trim();
                        break;
                    case "FMAD103":
                        PCPUB.m_record_id = dgv_list[0, e.RowIndex].Value.ToString().Trim();
                        break;
                    case "FMAD104":
                        PCPUB.m_record_id = dgv_list[0, e.RowIndex].Value.ToString().Trim();
                        break;
                    case "FMAD106":
                        PCPUB.m_record_id = dgv_list[0, e.RowIndex].Value.ToString().Trim();
                        break;
                    case "FMAD107":
                        PCPUB.m_record_id = dgv_list[0, e.RowIndex].Value.ToString().Trim();
                        break;
                    case "FMAD108":
                        PCPUB.m_record_id = dgv_list[0, e.RowIndex].Value.ToString().Trim();
                        break;
                    case "FMAD109":
                        PCPUB.m_record_id = dgv_list[0, e.RowIndex].Value.ToString().Trim();
                        break;
                }
                //
                if (PCPUB.m_record_id.Length > 0)
                {
                    tsb_edit.Enabled = true;
                    tsb_delete.Enabled = true;
                    tsb_print.Enabled = true;
                    fill_dgv_detail(e.RowIndex);
                }
            }
            catch
            {
                dgv_detail.Rows.Clear();
                PCPUB.m_record_id = String.Empty;
                PCPUB.m_record_date = String.Empty;
                tsb_edit.Enabled = false;
                tsb_delete.Enabled = false;
                tsb_print.Enabled = false;
            }

        }

        private void sc_main_list_Resize(object sender, EventArgs e)
        {
            sc_main_list.SplitterDistance = (int)(sc_main_list.Width * 0.75);
        }

        private void dgv_list_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            if (tsb_edit.Enabled == true)
            {
                PCPUB.m_entry_form_mode = "EDIT";
                load_child_form(this.Tag.ToString());
                tsb_refresh_Click(sender, e);
            }
        }

        // general 

        private void set_form_size()
        {
            this.Top = PCPUB.m_mdi_child_top;
            this.Left = PCPUB.m_mdi_child_left;
            this.Height = PCPUB.m_mdi_child_height;
            this.Width = PCPUB.m_mdi_child_width;
        }

        private void load_child_form(String p_id)
        {
            Form childForm;
            switch (p_id)
            {
                case "FMAD101":
                    childForm = new FMAD101();
                    childForm.ShowDialog();
                    break;
                case "FMAD102":
                    childForm = new FMAD102();
                    childForm.ShowDialog();
                    break;
                case "FMAD103":
                    childForm = new FMAD103();
                    childForm.ShowDialog();
                    break;
                case "FMAD104":
                    childForm = new FMAD104();
                    childForm.ShowDialog();
                    break;
                case "FMAD106":
                    childForm = new FMAD106();
                    childForm.ShowDialog();
                    break;
                case "FMAD107":
                    childForm = new FMAD107();
                    childForm.ShowDialog();
                    break;
                case "FMAD108":
                    childForm = new FMAD108();
                    childForm.ShowDialog();
                    break;
                case "FMAD109":
                    childForm = new FMAD109();
                    childForm.ShowDialog();
                    break;
                case "FMTR101":
                    childForm = new FMTR101();
                    childForm.ShowDialog();
                    break;
                case "FMTR102":
                    childForm = new FMTR102();
                    childForm.ShowDialog();
                    break;
                case "FMTR103":
                    childForm = new FMTR103();
                    childForm.ShowDialog();
                    break;
                case "FMTR201":
                    childForm = new FMTR201();
                    childForm.ShowDialog();
                    break;
                case "FMTR202":
                    childForm = new FMTR202();
                    childForm.ShowDialog();
                    break;
                case "FMTR301":
                    childForm = new FMTR301();
                    childForm.ShowDialog();
                    break;
                case "FMTR302":
                    childForm = new FMTR302();
                    childForm.ShowDialog();
                    break;
                case "FMTR303":
                    childForm = new FMTR303();
                    childForm.ShowDialog();
                    break;
                case "FMTR401":
                    childForm = new FMTR401();
                    childForm.ShowDialog();
                    break;
                case "FMTR402":
                    childForm = new FMTR402();
                    childForm.ShowDialog();
                    break;
                case "FMTR501":
                    childForm = new FMTR501();
                    childForm.ShowDialog();
                    break;
                case "FMTR502":
                    childForm = new FMTR502();
                    childForm.ShowDialog();
                    break;
                case "FMTR601":
                    childForm = new FMTR601();
                    childForm.ShowDialog();
                    break;
                case "FMTR602":
                    childForm = new FMTR602();
                    childForm.ShowDialog();
                    break;
                case "FMTR603":
                    if (PCPUB.m_record_status.Equals("Paid") && PCPUB.m_entry_form_mode.Equals("EDIT"))
                    {
                        PCMSG.ShowError("Payment already made and record status is 'Paid'. Record cannot be edited.");
                    }
                    else
                    {
                        childForm = new FMTR603();
                        childForm.ShowDialog();
                    }
                    break;
            }
        }

        private void fill_dgv_detail(int row_index)
        {
            int col_index = 0;
            int cols = 0;
            //int rows = 0;
            cols = dgv_list.ColumnCount;
            dgv_detail.Rows.Clear();
            for (col_index = 0; col_index < cols; col_index++)
            {
                dgv_detail.Rows.Add();
                dgv_detail[0, col_index].Value = dgv_list.Columns[col_index].HeaderText.ToString();
                dgv_detail[1, col_index].Value = dgv_list[col_index, row_index].Value.ToString();
            }
        }

        // admin

        private void load_FMAD101()
        {
            String db_connection_string = PCPUB.m_sqldb_connection.ToString();
            DataGridViewTextBoxColumn dgvc;
            //
            sql_conn = new SqlConnection(db_connection_string);
            sql_conn.Open();
            sql_comm.CommandText = " SELECT * FROM [vw_user] ORDER BY [user_id]";
            sql_comm.Connection = sql_conn;
            sql_adap.SelectCommand = sql_comm;
            //
            dgvc = new DataGridViewTextBoxColumn();
            dgvc.HeaderText = "User Id";
            dgvc.Name = "user_id";
            dgvc.DataPropertyName = dgvc.Name;
            dgvc.Width = 100;
            dgvc.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dgvc.FillWeight = dgvc.Width;
            dgv_list.Columns.Add(dgvc);
            //
            dgvc = new DataGridViewTextBoxColumn();
            dgvc.HeaderText = "User Name";
            dgvc.Name = "user_name";
            dgvc.DataPropertyName = dgvc.Name;
            dgvc.Width = 100;
            dgvc.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dgvc.FillWeight = dgvc.Width;
            dgv_list.Columns.Add(dgvc);
            //
            dgvc = new DataGridViewTextBoxColumn();
            dgvc.HeaderText = "User Role";
            dgvc.Name = "user_role_name";
            dgvc.DataPropertyName = dgvc.Name;
            dgvc.Width = 300;
            dgvc.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dgvc.FillWeight = dgvc.Width;
            dgv_list.Columns.Add(dgvc);
            //
            dt_list.TableName = "user";
            dt_list.Columns.Add("user_id");
            dt_list.Columns.Add("user_name");
            dt_list.Columns.Add("user_role_name");
            ds_list.Tables.Add(dt_list);
            bs_list.DataSource = ds_list;
            bs_list.DataMember = dt_list.TableName;
            dt_list.Clear();
            sql_adap.Fill(dt_list);
        }

        private void load_FMAD102()
        {
            String db_connection_string = PCPUB.m_sqldb_connection.ToString();
            DataGridViewTextBoxColumn dgvc;
            //
            sql_conn = new SqlConnection(db_connection_string);
            sql_conn.Open();
            sql_comm.CommandText = " SELECT * FROM [vw_vendor] WHERE [vendor_id] NOT IN ('YARNSTOCK') ORDER BY [vendor_id]";
            sql_comm.Connection = sql_conn;
            sql_adap.SelectCommand = sql_comm;
            //
            dgvc = new DataGridViewTextBoxColumn();
            dgvc.HeaderText = "Vendor Id";
            dgvc.Name = "vendor_id";
            dgvc.DataPropertyName = dgvc.Name;
            dgvc.Width = 200;
            dgvc.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dgvc.FillWeight = dgvc.Width;
            dgv_list.Columns.Add(dgvc);
            //
            dgvc = new DataGridViewTextBoxColumn();
            dgvc.HeaderText = "Vendor Name";
            dgvc.Name = "vendor_name";
            dgvc.DataPropertyName = dgvc.Name;
            dgvc.Width = 300;
            dgvc.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dgvc.FillWeight = dgvc.Width;
            dgv_list.Columns.Add(dgvc);
            //
            dgvc = new DataGridViewTextBoxColumn();
            dgvc.HeaderText = "City";
            dgvc.Name = "vendor_city";
            dgvc.DataPropertyName = dgvc.Name;
            dgvc.Width = 300;
            dgvc.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dgvc.FillWeight = dgvc.Width;
            dgv_list.Columns.Add(dgvc);
            //
            dgvc = new DataGridViewTextBoxColumn();
            dgvc.HeaderText = "Vendor Type";
            dgvc.Name = "vendor_type_name";
            dgvc.DataPropertyName = dgvc.Name;
            dgvc.Width = 300;
            dgvc.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dgvc.FillWeight = dgvc.Width;
            dgv_list.Columns.Add(dgvc);
            //
            dt_list.TableName = "vendor";
            dt_list.Columns.Add("vendor_id");
            dt_list.Columns.Add("vendor_name");
            dt_list.Columns.Add("vendor_city");
            dt_list.Columns.Add("vendor_type_name");
            ds_list.Tables.Add(dt_list);
            bs_list.DataSource = ds_list;
            bs_list.DataMember = dt_list.TableName;
            dt_list.Clear();
            sql_adap.Fill(dt_list);
        }

        private void load_FMAD103()
        {
            String db_connection_string = PCPUB.m_sqldb_connection.ToString();
            DataGridViewTextBoxColumn dgvc;
            //
            sql_conn = new SqlConnection(db_connection_string);
            sql_conn.Open();
            sql_comm.CommandText = " SELECT * FROM [vw_color] ORDER BY [color_id]";
            sql_comm.Connection = sql_conn;
            sql_adap.SelectCommand = sql_comm;
            //
            dgvc = new DataGridViewTextBoxColumn();
            dgvc.HeaderText = "Yarn Color Id";
            dgvc.Name = "color_id";
            dgvc.DataPropertyName = dgvc.Name;
            dgvc.Width = 100;
            dgvc.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dgvc.FillWeight = dgvc.Width;
            dgv_list.Columns.Add(dgvc);
            //
            dgvc = new DataGridViewTextBoxColumn();
            dgvc.HeaderText = "Yarn Color Name";
            dgvc.Name = "color_name";
            dgvc.DataPropertyName = dgvc.Name;
            dgvc.Width = 300;
            dgvc.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dgvc.FillWeight = dgvc.Width;
            dgv_list.Columns.Add(dgvc);
            //
            dt_list.TableName = "color";
            dt_list.Columns.Add("color_id");
            dt_list.Columns.Add("color_name");
            ds_list.Tables.Add(dt_list);
            bs_list.DataSource = ds_list;
            bs_list.DataMember = dt_list.TableName;
            dt_list.Clear();
            sql_adap.Fill(dt_list);
        }

        private void load_FMAD104()
        {
            String db_connection_string = PCPUB.m_sqldb_connection.ToString();
            DataGridViewTextBoxColumn dgvc;
            //
            sql_conn = new SqlConnection(db_connection_string);
            sql_conn.Open();
            sql_comm.CommandText = " SELECT * FROM [vw_yarn_count] ORDER BY [yarn_count_id]";
            sql_comm.Connection = sql_conn;
            sql_adap.SelectCommand = sql_comm;
            //
            dgvc = new DataGridViewTextBoxColumn();
            dgvc.HeaderText = "Yarn Count Id";
            dgvc.Name = "yarn_count_id";
            dgvc.DataPropertyName = dgvc.Name;
            dgvc.Width = 100;
            dgvc.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dgvc.FillWeight = dgvc.Width;
            dgv_list.Columns.Add(dgvc);
            //
            dgvc = new DataGridViewTextBoxColumn();
            dgvc.HeaderText = "Yarn Count Name";
            dgvc.Name = "yarn_count_name";
            dgvc.DataPropertyName = dgvc.Name;
            dgvc.Width = 300;
            dgvc.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dgvc.FillWeight = dgvc.Width;
            dgv_list.Columns.Add(dgvc);
            //
            dt_list.TableName = "yarn_count";
            dt_list.Columns.Add("yarn_count_id");
            dt_list.Columns.Add("yarn_count_name");
            ds_list.Tables.Add(dt_list);
            bs_list.DataSource = ds_list;
            bs_list.DataMember = dt_list.TableName;
            dt_list.Clear();
            sql_adap.Fill(dt_list);
        }

        private void load_FMAD106()
        {
            String db_connection_string = PCPUB.m_sqldb_connection.ToString();
            DataGridViewTextBoxColumn dgvc;
            //
            sql_conn = new SqlConnection(db_connection_string);
            sql_conn.Open();
            sql_comm.CommandText = " SELECT * FROM [vw_design] ORDER BY [design_id]";
            sql_comm.Connection = sql_conn;
            sql_adap.SelectCommand = sql_comm;
            //
            dgvc = new DataGridViewTextBoxColumn();
            dgvc.HeaderText = "Design Id";
            dgvc.Name = "design_id";
            dgvc.DataPropertyName = dgvc.Name;
            dgvc.Width = 100;
            dgvc.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dgvc.FillWeight = dgvc.Width;
            dgv_list.Columns.Add(dgvc);
            //
            dgvc = new DataGridViewTextBoxColumn();
            dgvc.HeaderText = "Design Name";
            dgvc.Name = "design_name";
            dgvc.DataPropertyName = dgvc.Name;
            dgvc.Width = 300;
            dgvc.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dgvc.FillWeight = dgvc.Width;
            dgv_list.Columns.Add(dgvc);
            //
            dt_list.TableName = "design";
            dt_list.Columns.Add("design_id");
            dt_list.Columns.Add("design_name");
            ds_list.Tables.Add(dt_list);
            bs_list.DataSource = ds_list;
            bs_list.DataMember = dt_list.TableName;
            dt_list.Clear();
            sql_adap.Fill(dt_list);
        }

        private void load_FMAD107()
        {
            String db_connection_string = PCPUB.m_sqldb_connection.ToString();
            DataGridViewTextBoxColumn dgvc;
            //
            sql_conn = new SqlConnection(db_connection_string);
            sql_conn.Open();
            sql_comm.CommandText = " SELECT * FROM [vw_size] ORDER BY [size_id]";
            sql_comm.Connection = sql_conn;
            sql_adap.SelectCommand = sql_comm;
            //
            dgvc = new DataGridViewTextBoxColumn();
            dgvc.HeaderText = "Size Id";
            dgvc.Name = "size_id";
            dgvc.DataPropertyName = dgvc.Name;
            dgvc.Width = 100;
            dgvc.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dgvc.FillWeight = dgvc.Width;
            dgv_list.Columns.Add(dgvc);
            //
            dgvc = new DataGridViewTextBoxColumn();
            dgvc.HeaderText = "Size Name";
            dgvc.Name = "size_name";
            dgvc.DataPropertyName = dgvc.Name;
            dgvc.Width = 300;
            dgvc.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dgvc.FillWeight = dgvc.Width;
            dgv_list.Columns.Add(dgvc);
            //
            dt_list.TableName = "size";
            dt_list.Columns.Add("size_id");
            dt_list.Columns.Add("size_name");
            ds_list.Tables.Add(dt_list);
            bs_list.DataSource = ds_list;
            bs_list.DataMember = dt_list.TableName;
            dt_list.Clear();
            sql_adap.Fill(dt_list);
        }

        private void load_FMAD108()
        {
            String db_connection_string = PCPUB.m_sqldb_connection.ToString();
            DataGridViewTextBoxColumn dgvc;
            //
            sql_conn = new SqlConnection(db_connection_string);
            sql_conn.Open();
            sql_comm.CommandText = " SELECT * FROM [vw_yarn_name] ORDER BY [yarn_name_id]";
            sql_comm.Connection = sql_conn;
            sql_adap.SelectCommand = sql_comm;
            //
            dgvc = new DataGridViewTextBoxColumn();
            dgvc.HeaderText = "Yarn Name Id";
            dgvc.Name = "yarn_name_id";
            dgvc.DataPropertyName = dgvc.Name;
            dgvc.Width = 100;
            dgvc.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dgvc.FillWeight = dgvc.Width;
            dgv_list.Columns.Add(dgvc);
            //
            dgvc = new DataGridViewTextBoxColumn();
            dgvc.HeaderText = "Yarn Name";
            dgvc.Name = "yarn_name_name";
            dgvc.DataPropertyName = dgvc.Name;
            dgvc.Width = 300;
            dgvc.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dgvc.FillWeight = dgvc.Width;
            dgv_list.Columns.Add(dgvc);
            //
            dt_list.TableName = "yarn_name";
            dt_list.Columns.Add("yarn_name_id");
            dt_list.Columns.Add("yarn_name_name");
            ds_list.Tables.Add(dt_list);
            bs_list.DataSource = ds_list;
            bs_list.DataMember = dt_list.TableName;
            dt_list.Clear();
            sql_adap.Fill(dt_list);
        }

        private void load_FMAD109()
        {
            String db_connection_string = PCPUB.m_sqldb_connection.ToString();
            DataGridViewTextBoxColumn dgvc;
            //
            sql_conn = new SqlConnection(db_connection_string);
            sql_conn.Open();
            sql_comm.CommandText = " SELECT [city_id],[city_name] FROM [vw_city] ORDER BY [city_id]";
            sql_comm.Connection = sql_conn;
            sql_adap.SelectCommand = sql_comm;
            //
            dgvc = new DataGridViewTextBoxColumn();
            dgvc.HeaderText = "City Id";
            dgvc.Name = "city_id";
            dgvc.DataPropertyName = dgvc.Name;
            dgvc.Width = 100;
            dgvc.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dgvc.FillWeight = dgvc.Width;
            dgv_list.Columns.Add(dgvc);
            //
            dgvc = new DataGridViewTextBoxColumn();
            dgvc.HeaderText = "City Name";
            dgvc.Name = "city_name";
            dgvc.DataPropertyName = dgvc.Name;
            dgvc.Width = 300;
            dgvc.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dgvc.FillWeight = dgvc.Width;
            dgv_list.Columns.Add(dgvc);
            //
            dt_list.TableName = "city";
            dt_list.Columns.Add("city_id");
            dt_list.Columns.Add("city_name");
            ds_list.Tables.Add(dt_list);
            bs_list.DataSource = ds_list;
            bs_list.DataMember = dt_list.TableName;
            dt_list.Clear();
            sql_adap.Fill(dt_list);
        }

        // tran

        private void load_FMTR101()
        {
            String strQuery = String.Empty;
            String db_connection_string = PCPUB.m_sqldb_connection.ToString();
            DataGridViewTextBoxColumn dgvc;
            //
            strQuery = String.Empty;
            strQuery += " SELECT * ";
            strQuery += " FROM [vw_yarn_purchase_iw] ";
            strQuery += " WHERE CONVERT(VARCHAR(10),[yarn_purchase_iw_date],121) = '" + PCPUB.m_tran_date.ToString("yyyy-MM-dd") + "'";
            strQuery += " ORDER BY [yarn_purchase_iw_id]";
            sql_conn = new SqlConnection(db_connection_string);
            sql_conn.Open();
            sql_comm.CommandText = strQuery;
            sql_comm.Connection = sql_conn;
            sql_adap.SelectCommand = sql_comm;
            //
            dgvc = new DataGridViewTextBoxColumn();
            dgvc.HeaderText = "Date";
            dgvc.Name = "yarn_purchase_iw_date";
            dgvc.DataPropertyName = dgvc.Name;
            dgvc.Width = 100;
            dgvc.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dgvc.FillWeight = dgvc.Width;
            dgv_list.Columns.Add(dgvc);
            //
            dgvc = new DataGridViewTextBoxColumn();
            dgvc.HeaderText = "Id";
            dgvc.Name = "yarn_purchase_iw_id";
            dgvc.DataPropertyName = dgvc.Name;
            dgvc.Width = 100;
            dgvc.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dgvc.FillWeight = dgvc.Width;
            dgv_list.Columns.Add(dgvc);
            //
            dgvc = new DataGridViewTextBoxColumn();
            dgvc.HeaderText = "Yarn Vendor";
            dgvc.Name = "yarn_vendor_name";
            dgvc.DataPropertyName = dgvc.Name;
            dgvc.Width = 300;
            dgvc.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dgvc.FillWeight = dgvc.Width;
            dgv_list.Columns.Add(dgvc);
            //
            dgvc = new DataGridViewTextBoxColumn();
            dgvc.HeaderText = "Transport";
            dgvc.Name = "transport_name";
            dgvc.DataPropertyName = dgvc.Name;
            dgvc.Width = 300;
            dgvc.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dgvc.FillWeight = dgvc.Width;
            dgv_list.Columns.Add(dgvc);
            //
            dt_list.TableName = "yarn_purchase_iw";
            dt_list.Columns.Add("yarn_purchase_iw_id");
            dt_list.Columns.Add("yarn_purchase_iw_date");
            dt_list.Columns.Add("yarn_vendor_name");
            dt_list.Columns.Add("transport_name");
            //
            ds_list.Tables.Add(dt_list);
            bs_list.DataSource = ds_list;
            bs_list.DataMember = "yarn_purchase_iw";
            dt_list.Clear();
            sql_adap.Fill(dt_list);
            tsb_print.Enabled = true;
        }

        private void load_FMTR102()
        {
            String strQuery = String.Empty;
            String db_connection_string = PCPUB.m_sqldb_connection.ToString();
            DataGridViewTextBoxColumn dgvc;
            //
            strQuery = String.Empty;
            strQuery += " SELECT * ";
            strQuery += " FROM [vw_yarn_sales_ow] ";
            strQuery += " WHERE CONVERT(VARCHAR(10),[yarn_sales_ow_date],121) = '" + PCPUB.m_tran_date.ToString("yyyy-MM-dd") + "'";
            strQuery += " ORDER BY [yarn_sales_ow_id]";
            sql_conn = new SqlConnection(db_connection_string);
            sql_conn.Open();
            sql_comm.CommandText = strQuery;
            sql_comm.Connection = sql_conn;
            sql_adap.SelectCommand = sql_comm;
            //
            dgvc = new DataGridViewTextBoxColumn();
            dgvc.HeaderText = "Date";
            dgvc.Name = "yarn_sales_ow_date";
            dgvc.DataPropertyName = dgvc.Name;
            dgvc.Width = 100;
            dgvc.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dgvc.FillWeight = dgvc.Width;
            dgv_list.Columns.Add(dgvc);
            //
            dgvc = new DataGridViewTextBoxColumn();
            dgvc.HeaderText = "Id";
            dgvc.Name = "yarn_sales_ow_id";
            dgvc.DataPropertyName = dgvc.Name;
            dgvc.Width = 100;
            dgvc.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dgvc.FillWeight = dgvc.Width;
            dgv_list.Columns.Add(dgvc);
            //
            dgvc = new DataGridViewTextBoxColumn();
            dgvc.HeaderText = "Yarn Buyer";
            dgvc.Name = "yarn_buyer_name";
            dgvc.DataPropertyName = dgvc.Name;
            dgvc.Width = 300;
            dgvc.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dgvc.FillWeight = dgvc.Width;
            dgv_list.Columns.Add(dgvc);
            //
            dgvc = new DataGridViewTextBoxColumn();
            dgvc.HeaderText = "Transport";
            dgvc.Name = "transport_name";
            dgvc.DataPropertyName = dgvc.Name;
            dgvc.Width = 300;
            dgvc.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dgvc.FillWeight = dgvc.Width;
            dgv_list.Columns.Add(dgvc);
            //
            dt_list.TableName = "yarn_sales_ow";
            dt_list.Columns.Add("yarn_sales_ow_id");
            dt_list.Columns.Add("yarn_sales_ow_date");
            dt_list.Columns.Add("yarn_buyer_name");
            dt_list.Columns.Add("transport_name");
            //
            ds_list.Tables.Add(dt_list);
            bs_list.DataSource = ds_list;
            bs_list.DataMember = "yarn_sales_ow";
            dt_list.Clear();
            sql_adap.Fill(dt_list);
            tsb_print.Enabled = true;
        }

        private void load_FMTR103()
        {
            String strQuery = String.Empty;
            String db_connection_string = PCPUB.m_sqldb_connection.ToString();
            DataGridViewTextBoxColumn dgvc;
            //
            strQuery = String.Empty;
            strQuery += " SELECT [yarn_material_iw_date],[yarn_material_iw_id],[yarn_vendor_name],[transport_name]";
            strQuery += " FROM [vw_yarn_material_iw] ";
            strQuery += " WHERE CONVERT(VARCHAR(10),[yarn_material_iw_date],121) = '" + PCPUB.m_tran_date.ToString("yyyy-MM-dd") + "'";
            strQuery += " ORDER BY [yarn_material_iw_id]";
            sql_conn = new SqlConnection(db_connection_string);
            sql_conn.Open();
            sql_comm.CommandText = strQuery;
            sql_comm.Connection = sql_conn;
            sql_adap.SelectCommand = sql_comm;
            //
            dgvc = new DataGridViewTextBoxColumn();
            dgvc.HeaderText = "Date";
            dgvc.Name = "yarn_material_iw_date";
            dgvc.DataPropertyName = dgvc.Name;
            dgvc.Width = 100;
            dgvc.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dgvc.FillWeight = dgvc.Width;
            dgv_list.Columns.Add(dgvc);
            //
            dgvc = new DataGridViewTextBoxColumn();
            dgvc.HeaderText = "Id";
            dgvc.Name = "yarn_material_iw_id";
            dgvc.DataPropertyName = dgvc.Name;
            dgvc.Width = 100;
            dgvc.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dgvc.FillWeight = dgvc.Width;
            dgv_list.Columns.Add(dgvc);
            //
            dgvc = new DataGridViewTextBoxColumn();
            dgvc.HeaderText = "Yarn Vendor";
            dgvc.Name = "yarn_vendor_name";
            dgvc.DataPropertyName = dgvc.Name;
            dgvc.Width = 300;
            dgvc.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dgvc.FillWeight = dgvc.Width;
            dgv_list.Columns.Add(dgvc);
            //
            dgvc = new DataGridViewTextBoxColumn();
            dgvc.HeaderText = "Transport";
            dgvc.Name = "transport_name";
            dgvc.DataPropertyName = dgvc.Name;
            dgvc.Width = 300;
            dgvc.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dgvc.FillWeight = dgvc.Width;
            dgv_list.Columns.Add(dgvc);
            //
            dt_list.TableName = "yarn_material_iw";
            dt_list.Columns.Add("yarn_material_iw_id");
            dt_list.Columns.Add("yarn_material_iw_date");
            dt_list.Columns.Add("yarn_vendor_name");
            dt_list.Columns.Add("transport_name");
            //
            ds_list.Tables.Add(dt_list);
            bs_list.DataSource = ds_list;
            bs_list.DataMember = "yarn_material_iw";
            dt_list.Clear();
            sql_adap.Fill(dt_list);
            tsb_print.Enabled = true;
        }

        private void load_FMTR201()
        {
            String strQuery = String.Empty;
            String db_connection_string = PCPUB.m_sqldb_connection.ToString();
            DataGridViewTextBoxColumn dgvc;
            //
            strQuery = String.Empty;
            strQuery += " SELECT * ";
            strQuery += " FROM [vw_dyeing_ow] ";
            strQuery += " WHERE CONVERT(VARCHAR(10),[dyeing_ow_date],121) = '" + PCPUB.m_tran_date.ToString("yyyy-MM-dd") + "'";
            strQuery += " ORDER BY [dyeing_ow_id]";
            sql_conn = new SqlConnection(db_connection_string);
            sql_conn.Open();
            sql_comm.CommandText = strQuery;
            sql_comm.Connection = sql_conn;
            sql_adap.SelectCommand = sql_comm;
            //
            dgvc = new DataGridViewTextBoxColumn();
            dgvc.HeaderText = "Date";
            dgvc.Name = "dyeing_ow_date";
            dgvc.DataPropertyName = dgvc.Name;
            dgvc.Width = 100;
            dgvc.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dgvc.FillWeight = dgvc.Width;
            dgv_list.Columns.Add(dgvc);
            //
            dgvc = new DataGridViewTextBoxColumn();
            dgvc.HeaderText = "Id";
            dgvc.Name = "dyeing_ow_id";
            dgvc.DataPropertyName = dgvc.Name;
            dgvc.Width = 100;
            dgvc.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dgvc.FillWeight = dgvc.Width;
            dgv_list.Columns.Add(dgvc);
            //
            dgvc = new DataGridViewTextBoxColumn();
            dgvc.HeaderText = "Dyer";
            dgvc.Name = "dyer_name";
            dgvc.DataPropertyName = dgvc.Name;
            dgvc.Width = 300;
            dgvc.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dgvc.FillWeight = dgvc.Width;
            dgv_list.Columns.Add(dgvc);
            //
            dgvc = new DataGridViewTextBoxColumn();
            dgvc.HeaderText = "Transport";
            dgvc.Name = "transport_name";
            dgvc.DataPropertyName = dgvc.Name;
            dgvc.Width = 300;
            dgvc.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dgvc.FillWeight = dgvc.Width;
            dgv_list.Columns.Add(dgvc);
            //
            dt_list.TableName = "dyeing_ow";
            dt_list.Columns.Add("dyeing_ow_id");
            dt_list.Columns.Add("dyeing_ow_date");
            dt_list.Columns.Add("dyer_name");
            dt_list.Columns.Add("transport_name");
            //
            ds_list.Tables.Add(dt_list);
            bs_list.DataSource = ds_list;
            bs_list.DataMember = "dyeing_ow";
            dt_list.Clear();
            sql_adap.Fill(dt_list);
            tsb_print.Enabled = true;
        }

        private void load_FMTR202()
        {
            String strQuery = String.Empty;
            String db_connection_string = PCPUB.m_sqldb_connection.ToString();
            DataGridViewTextBoxColumn dgvc;
            //
            strQuery = String.Empty;
            strQuery += " SELECT * ";
            strQuery += " FROM [vw_dyeing_iw] ";
            strQuery += " WHERE CONVERT(VARCHAR(10),[dyeing_iw_date],121) = '" + PCPUB.m_tran_date.ToString("yyyy-MM-dd") + "'";
            strQuery += " ORDER BY [dyeing_iw_id]";
            sql_conn = new SqlConnection(db_connection_string);
            sql_conn.Open();
            sql_comm.CommandText = strQuery;
            sql_comm.Connection = sql_conn;
            sql_adap.SelectCommand = sql_comm;
            //
            dgvc = new DataGridViewTextBoxColumn();
            dgvc.HeaderText = "Date";
            dgvc.Name = "dyeing_iw_date";
            dgvc.DataPropertyName = dgvc.Name;
            dgvc.Width = 100;
            dgvc.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dgvc.FillWeight = dgvc.Width;
            dgv_list.Columns.Add(dgvc);
            //
            dgvc = new DataGridViewTextBoxColumn();
            dgvc.HeaderText = "Id";
            dgvc.Name = "dyeing_iw_id";
            dgvc.DataPropertyName = dgvc.Name;
            dgvc.Width = 100;
            dgvc.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dgvc.FillWeight = dgvc.Width;
            dgv_list.Columns.Add(dgvc);
            //
            dgvc = new DataGridViewTextBoxColumn();
            dgvc.HeaderText = "Dyer";
            dgvc.Name = "dyer_name";
            dgvc.DataPropertyName = dgvc.Name;
            dgvc.Width = 300;
            dgvc.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dgvc.FillWeight = dgvc.Width;
            dgv_list.Columns.Add(dgvc);
            //
            dgvc = new DataGridViewTextBoxColumn();
            dgvc.HeaderText = "Transport";
            dgvc.Name = "transport_name";
            dgvc.DataPropertyName = dgvc.Name;
            dgvc.Width = 300;
            dgvc.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dgvc.FillWeight = dgvc.Width;
            dgv_list.Columns.Add(dgvc);
            //
            dt_list.TableName = "dyeing_iw";
            dt_list.Columns.Add("dyeing_iw_id");
            dt_list.Columns.Add("dyeing_iw_date");
            dt_list.Columns.Add("dyer_name");
            dt_list.Columns.Add("transport_name");
            //
            ds_list.Tables.Add(dt_list);
            bs_list.DataSource = ds_list;
            bs_list.DataMember = "dyeing_iw";
            dt_list.Clear();
            sql_adap.Fill(dt_list);
            tsb_print.Enabled = true;
        }

        private void load_FMTR301()
        {
            String strQuery = String.Empty;
            String db_connection_string = PCPUB.m_sqldb_connection.ToString();
            DataGridViewTextBoxColumn dgvc;
            //
            strQuery = String.Empty;
            strQuery += " SELECT * ";
            strQuery += " FROM [vw_weaving_ow] ";
            strQuery += " WHERE CONVERT(VARCHAR(10),[weaving_ow_date],121) = '" + PCPUB.m_tran_date.ToString("yyyy-MM-dd") + "'";
            strQuery += " ORDER BY [weaving_ow_id]";
            sql_conn = new SqlConnection(db_connection_string);
            sql_conn.Open();
            sql_comm.CommandText = strQuery;
            sql_comm.Connection = sql_conn;
            sql_adap.SelectCommand = sql_comm;
            //
            dgvc = new DataGridViewTextBoxColumn();
            dgvc.HeaderText = "Date";
            dgvc.Name = "weaving_ow_date";
            dgvc.DataPropertyName = dgvc.Name;
            dgvc.Width = 100;
            dgvc.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dgvc.FillWeight = dgvc.Width;
            dgv_list.Columns.Add(dgvc);
            //
            dgvc = new DataGridViewTextBoxColumn();
            dgvc.HeaderText = "Id";
            dgvc.Name = "weaving_ow_id";
            dgvc.DataPropertyName = dgvc.Name;
            dgvc.Width = 100;
            dgvc.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dgvc.FillWeight = dgvc.Width;
            dgv_list.Columns.Add(dgvc);
            //
            dgvc = new DataGridViewTextBoxColumn();
            dgvc.HeaderText = "Weaver";
            dgvc.Name = "weaver_name";
            dgvc.DataPropertyName = dgvc.Name;
            dgvc.Width = 300;
            dgvc.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dgvc.FillWeight = dgvc.Width;
            dgv_list.Columns.Add(dgvc);
            //
            dgvc = new DataGridViewTextBoxColumn();
            dgvc.HeaderText = "Transport";
            dgvc.Name = "transport_name";
            dgvc.DataPropertyName = dgvc.Name;
            dgvc.Width = 300;
            dgvc.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dgvc.FillWeight = dgvc.Width;
            dgv_list.Columns.Add(dgvc);
            //
            dt_list.TableName = "weaving_ow";
            dt_list.Columns.Add("weaving_ow_id");
            dt_list.Columns.Add("weaving_ow_date");
            dt_list.Columns.Add("weaver_name");
            dt_list.Columns.Add("transport_name");
            ds_list.Tables.Add(dt_list);
            bs_list.DataSource = ds_list;
            bs_list.DataMember = "weaving_ow";
            dt_list.Clear();
            sql_adap.Fill(dt_list);
        }

        private void load_FMTR302()
        {
            String strQuery = String.Empty;
            String db_connection_string = PCPUB.m_sqldb_connection.ToString();
            DataGridViewTextBoxColumn dgvc;
            //
            strQuery = String.Empty;
            strQuery += " SELECT * ";
            strQuery += " FROM [vw_weaving_iw] ";
            strQuery += " WHERE CONVERT(VARCHAR(10),[weaving_iw_date],121) = '" + PCPUB.m_tran_date.ToString("yyyy-MM-dd") + "'";
            strQuery += " ORDER BY [weaving_iw_id]";
            sql_conn = new SqlConnection(db_connection_string);
            sql_conn.Open();
            sql_comm.CommandText = strQuery;
            sql_comm.Connection = sql_conn;
            sql_adap.SelectCommand = sql_comm;
            //
            dgvc = new DataGridViewTextBoxColumn();
            dgvc.HeaderText = "Date";
            dgvc.Name = "weaving_iw_date";
            dgvc.DataPropertyName = dgvc.Name;
            dgvc.Width = 100;
            dgvc.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dgvc.FillWeight = dgvc.Width;
            dgv_list.Columns.Add(dgvc);
            //
            dgvc = new DataGridViewTextBoxColumn();
            dgvc.HeaderText = "Id";
            dgvc.Name = "weaving_iw_id";
            dgvc.DataPropertyName = dgvc.Name;
            dgvc.Width = 100;
            dgvc.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dgvc.FillWeight = dgvc.Width;
            dgv_list.Columns.Add(dgvc);
            //
            dgvc = new DataGridViewTextBoxColumn();
            dgvc.HeaderText = "Weaver";
            dgvc.Name = "weaver_name";
            dgvc.DataPropertyName = dgvc.Name;
            dgvc.Width = 300;
            dgvc.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dgvc.FillWeight = dgvc.Width;
            dgv_list.Columns.Add(dgvc);
            //
            dgvc = new DataGridViewTextBoxColumn();
            dgvc.HeaderText = "Transport";
            dgvc.Name = "transport_name";
            dgvc.DataPropertyName = dgvc.Name;
            dgvc.Width = 300;
            dgvc.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dgvc.FillWeight = dgvc.Width;
            dgv_list.Columns.Add(dgvc);
            //
            dt_list.TableName = "weaving_iw";
            dt_list.Columns.Add("weaving_iw_id");
            dt_list.Columns.Add("weaving_iw_date");
            dt_list.Columns.Add("weaver_name");
            dt_list.Columns.Add("transport_name");
            ds_list.Tables.Add(dt_list);
            bs_list.DataSource = ds_list;
            bs_list.DataMember = "weaving_iw";
            dt_list.Clear();
            sql_adap.Fill(dt_list);
        }

        private void load_FMTR303()
        {
            String strQuery = String.Empty;
            String db_connection_string = PCPUB.m_sqldb_connection.ToString();
            DataGridViewTextBoxColumn dgvc;
            //
            strQuery = String.Empty;
            strQuery += " SELECT * ";
            strQuery += " FROM [vw_weaving_adj] ";
            strQuery += " WHERE CONVERT(VARCHAR(10),[weaving_adj_date],121) = '" + PCPUB.m_tran_date.ToString("yyyy-MM-dd") + "'";
            strQuery += " ORDER BY [weaving_adj_id]";
            sql_conn = new SqlConnection(db_connection_string);
            sql_conn.Open();
            sql_comm.CommandText = strQuery;
            sql_comm.Connection = sql_conn;
            sql_adap.SelectCommand = sql_comm;
            //
            dgvc = new DataGridViewTextBoxColumn();
            dgvc.HeaderText = "Date";
            dgvc.Name = "weaving_adj_date";
            dgvc.DataPropertyName = dgvc.Name;
            dgvc.Width = 100;
            dgvc.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dgvc.FillWeight = dgvc.Width;
            dgv_list.Columns.Add(dgvc);
            //
            dgvc = new DataGridViewTextBoxColumn();
            dgvc.HeaderText = "Id";
            dgvc.Name = "weaving_adj_id";
            dgvc.DataPropertyName = dgvc.Name;
            dgvc.Width = 100;
            dgvc.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dgvc.FillWeight = dgvc.Width;
            dgv_list.Columns.Add(dgvc);
            //
            dgvc = new DataGridViewTextBoxColumn();
            dgvc.HeaderText = "Weaver";
            dgvc.Name = "weaver_name";
            dgvc.DataPropertyName = dgvc.Name;
            dgvc.Width = 300;
            dgvc.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dgvc.FillWeight = dgvc.Width;
            dgv_list.Columns.Add(dgvc);
            //
            //dgvc = new DataGridViewTextBoxColumn();
            //dgvc.HeaderText = "Transport";
            //dgvc.Name = "transport_name";
            //dgvc.DataPropertyName = dgvc.Name;
            //dgvc.Width = 300;
            //dgvc.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            //dgvc.FillWeight = dgvc.Width;
            //dgv_list.Columns.Add(dgvc);
            //
            dt_list.TableName = "weaving_adj";
            dt_list.Columns.Add("weaving_adj_id");
            dt_list.Columns.Add("weaving_adj_date");
            dt_list.Columns.Add("weaver_name");
            //dt_list.Columns.Add("transport_name");
            ds_list.Tables.Add(dt_list);
            bs_list.DataSource = ds_list;
            bs_list.DataMember = "weaving_adj";
            dt_list.Clear();
            sql_adap.Fill(dt_list);
        }

        private void load_FMTR401()
        {
            String strQuery = String.Empty;
            String db_connection_string = PCPUB.m_sqldb_connection.ToString();
            DataGridViewTextBoxColumn dgvc;
            //
            strQuery = String.Empty;
            strQuery += " SELECT * ";
            strQuery += " FROM [vw_washing_ow] ";
            strQuery += " WHERE CONVERT(VARCHAR(10),[washing_ow_date],121) = '" + PCPUB.m_tran_date.ToString("yyyy-MM-dd") + "'";
            strQuery += " ORDER BY [washing_ow_id]";
            sql_conn = new SqlConnection(db_connection_string);
            sql_conn.Open();
            sql_comm.CommandText = strQuery;
            sql_comm.Connection = sql_conn;
            sql_adap.SelectCommand = sql_comm;
            //
            dgvc = new DataGridViewTextBoxColumn();
            dgvc.HeaderText = "Date";
            dgvc.Name = "washing_ow_date";
            dgvc.DataPropertyName = dgvc.Name;
            dgvc.Width = 100;
            dgvc.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dgvc.FillWeight = dgvc.Width;
            dgv_list.Columns.Add(dgvc);
            //
            dgvc = new DataGridViewTextBoxColumn();
            dgvc.HeaderText = "Id";
            dgvc.Name = "washing_ow_id";
            dgvc.DataPropertyName = dgvc.Name;
            dgvc.Width = 100;
            dgvc.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dgvc.FillWeight = dgvc.Width;
            dgv_list.Columns.Add(dgvc);
            //
            dgvc = new DataGridViewTextBoxColumn();
            dgvc.HeaderText = "Washer";
            dgvc.Name = "washer_name";
            dgvc.DataPropertyName = dgvc.Name;
            dgvc.Width = 300;
            dgvc.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dgvc.FillWeight = dgvc.Width;
            dgv_list.Columns.Add(dgvc);
            //
            dgvc = new DataGridViewTextBoxColumn();
            dgvc.HeaderText = "Transport";
            dgvc.Name = "transport_name";
            dgvc.DataPropertyName = dgvc.Name;
            dgvc.Width = 300;
            dgvc.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dgvc.FillWeight = dgvc.Width;
            dgv_list.Columns.Add(dgvc);
            //
            dt_list.TableName = "washing_ow";
            dt_list.Columns.Add("washing_ow_id");
            dt_list.Columns.Add("washing_ow_date");
            dt_list.Columns.Add("washer_name");
            dt_list.Columns.Add("transport_name");
            ds_list.Tables.Add(dt_list);
            bs_list.DataSource = ds_list;
            bs_list.DataMember = "washing_ow";
            dt_list.Clear();
            sql_adap.Fill(dt_list);
        }

        private void load_FMTR402()
        {
            String strQuery = String.Empty;
            String db_connection_string = PCPUB.m_sqldb_connection.ToString();
            DataGridViewTextBoxColumn dgvc;
            //
            strQuery = String.Empty;
            strQuery += " SELECT * ";
            strQuery += " FROM [vw_washing_iw] ";
            strQuery += " WHERE CONVERT(VARCHAR(10),[washing_iw_date],121) = '" + PCPUB.m_tran_date.ToString("yyyy-MM-dd") + "'";
            strQuery += " ORDER BY [washing_iw_id]";
            sql_conn = new SqlConnection(db_connection_string);
            sql_conn.Open();
            sql_comm.CommandText = strQuery;
            sql_comm.Connection = sql_conn;
            sql_adap.SelectCommand = sql_comm;
            //
            dgvc = new DataGridViewTextBoxColumn();
            dgvc.HeaderText = "Date";
            dgvc.Name = "washing_iw_date";
            dgvc.DataPropertyName = dgvc.Name;
            dgvc.Width = 100;
            dgvc.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dgvc.FillWeight = dgvc.Width;
            dgv_list.Columns.Add(dgvc);
            //
            dgvc = new DataGridViewTextBoxColumn();
            dgvc.HeaderText = "Id";
            dgvc.Name = "washing_iw_id";
            dgvc.DataPropertyName = dgvc.Name;
            dgvc.Width = 100;
            dgvc.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dgvc.FillWeight = dgvc.Width;
            dgv_list.Columns.Add(dgvc);
            //
            dgvc = new DataGridViewTextBoxColumn();
            dgvc.HeaderText = "Washer";
            dgvc.Name = "washer_name";
            dgvc.DataPropertyName = dgvc.Name;
            dgvc.Width = 300;
            dgvc.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dgvc.FillWeight = dgvc.Width;
            dgv_list.Columns.Add(dgvc);
            //
            dgvc = new DataGridViewTextBoxColumn();
            dgvc.HeaderText = "Transport";
            dgvc.Name = "transport_name";
            dgvc.DataPropertyName = dgvc.Name;
            dgvc.Width = 300;
            dgvc.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dgvc.FillWeight = dgvc.Width;
            dgv_list.Columns.Add(dgvc);
            //
            dt_list.TableName = "washing_iw";
            dt_list.Columns.Add("washing_iw_id");
            dt_list.Columns.Add("washing_iw_date");
            dt_list.Columns.Add("washer_name");
            dt_list.Columns.Add("transport_name");
            ds_list.Tables.Add(dt_list);
            bs_list.DataSource = ds_list;
            bs_list.DataMember = "washing_iw";
            dt_list.Clear();
            sql_adap.Fill(dt_list);
        }

        private void load_FMTR501()
        {
            String strQuery = String.Empty;
            String db_connection_string = PCPUB.m_sqldb_connection.ToString();
            DataGridViewTextBoxColumn dgvc;
            //
            strQuery = String.Empty;
            strQuery += " SELECT tailoring_ow_date, tailoring_ow_id, tailor_name, transport_name";
            strQuery += " FROM [vw_tailoring_ow] ";
            strQuery += " WHERE CONVERT(VARCHAR(10),[tailoring_ow_date],121) = '" + PCPUB.m_tran_date.ToString("yyyy-MM-dd") + "'";
            strQuery += " ORDER BY [tailoring_ow_id]";
            sql_conn = new SqlConnection(db_connection_string);
            sql_conn.Open();
            sql_comm.CommandText = strQuery;
            sql_comm.Connection = sql_conn;
            sql_adap.SelectCommand = sql_comm;
            //
            dgvc = new DataGridViewTextBoxColumn();
            dgvc.HeaderText = "Date";
            dgvc.Name = "tailoring_ow_date";
            dgvc.DataPropertyName = dgvc.Name;
            dgvc.Width = 100;
            dgvc.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dgvc.FillWeight = dgvc.Width;
            dgv_list.Columns.Add(dgvc);
            //
            dgvc = new DataGridViewTextBoxColumn();
            dgvc.HeaderText = "Id";
            dgvc.Name = "tailoring_ow_id";
            dgvc.DataPropertyName = dgvc.Name;
            dgvc.Width = 100;
            dgvc.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dgvc.FillWeight = dgvc.Width;
            dgv_list.Columns.Add(dgvc);
            //
            dgvc = new DataGridViewTextBoxColumn();
            dgvc.HeaderText = "Tailor";
            dgvc.Name = "tailor_name";
            dgvc.DataPropertyName = dgvc.Name;
            dgvc.Width = 300;
            dgvc.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dgvc.FillWeight = dgvc.Width;
            dgv_list.Columns.Add(dgvc);
            //
            dgvc = new DataGridViewTextBoxColumn();
            dgvc.HeaderText = "Transport";
            dgvc.Name = "transport_name";
            dgvc.DataPropertyName = dgvc.Name;
            dgvc.Width = 300;
            dgvc.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dgvc.FillWeight = dgvc.Width;
            dgv_list.Columns.Add(dgvc);
            //
            dt_list.TableName = "tailoring_ow";
            dt_list.Columns.Add("tailoring_ow_id");
            dt_list.Columns.Add("tailoring_ow_date");
            dt_list.Columns.Add("tailor_name");
            dt_list.Columns.Add("transport_name");
            ds_list.Tables.Add(dt_list);
            bs_list.DataSource = ds_list;
            bs_list.DataMember = "tailoring_ow";
            dt_list.Clear();
            sql_adap.Fill(dt_list);
        }

        private void load_FMTR502()
        {
            String strQuery = String.Empty;
            String db_connection_string = PCPUB.m_sqldb_connection.ToString();
            DataGridViewTextBoxColumn dgvc;
            //
            strQuery = String.Empty;
            strQuery += " SELECT tailoring_iw_date, tailoring_iw_id, tailor_name, transport_name";
            strQuery += " FROM [vw_tailoring_iw] ";
            strQuery += " WHERE CONVERT(VARCHAR(10),[tailoring_iw_date],121) = '" + PCPUB.m_tran_date.ToString("yyyy-MM-dd") + "'";
            strQuery += " ORDER BY [tailoring_iw_id]";
            sql_conn = new SqlConnection(db_connection_string);
            sql_conn.Open();
            sql_comm.CommandText = strQuery;
            sql_comm.Connection = sql_conn;
            sql_adap.SelectCommand = sql_comm;
            //
            dgvc = new DataGridViewTextBoxColumn();
            dgvc.HeaderText = "Date";
            dgvc.Name = "tailoring_iw_date";
            dgvc.DataPropertyName = dgvc.Name;
            dgvc.Width = 100;
            dgvc.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dgvc.FillWeight = dgvc.Width;
            dgv_list.Columns.Add(dgvc);
            //
            dgvc = new DataGridViewTextBoxColumn();
            dgvc.HeaderText = "Id";
            dgvc.Name = "tailoring_iw_id";
            dgvc.DataPropertyName = dgvc.Name;
            dgvc.Width = 100;
            dgvc.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dgvc.FillWeight = dgvc.Width;
            dgv_list.Columns.Add(dgvc);
            //
            dgvc = new DataGridViewTextBoxColumn();
            dgvc.HeaderText = "Tailor";
            dgvc.Name = "tailor_name";
            dgvc.DataPropertyName = dgvc.Name;
            dgvc.Width = 300;
            dgvc.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dgvc.FillWeight = dgvc.Width;
            dgv_list.Columns.Add(dgvc);
            //
            dgvc = new DataGridViewTextBoxColumn();
            dgvc.HeaderText = "Transport";
            dgvc.Name = "transport_name";
            dgvc.DataPropertyName = dgvc.Name;
            dgvc.Width = 300;
            dgvc.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dgvc.FillWeight = dgvc.Width;
            dgv_list.Columns.Add(dgvc);
            //
            dt_list.TableName = "tailoring_iw";
            dt_list.Columns.Add("tailoring_iw_id");
            dt_list.Columns.Add("tailoring_iw_date");
            dt_list.Columns.Add("tailor_name");
            dt_list.Columns.Add("transport_name");
            ds_list.Tables.Add(dt_list);
            bs_list.DataSource = ds_list;
            bs_list.DataMember = "tailoring_iw";
            dt_list.Clear();
            sql_adap.Fill(dt_list);
        }

        private void load_FMTR601()
        {
            String strQuery = String.Empty;
            String db_connection_string = PCPUB.m_sqldb_connection.ToString();
            DataGridViewTextBoxColumn dgvc;
            //
            strQuery = String.Empty;
            strQuery += " SELECT CONVERT(VARCHAR(10),[payment_date],103) payment_date,";
            strQuery += " [payment_id] payment_id,";
            strQuery += " [vendor_type_id] vendor_type_id,";
            strQuery += " [vendor_type_name] vendor_type_name,";
            strQuery += " [vendor_id] vendor_id,";
            strQuery += " [vendor_name] vendor_name,";
            strQuery += " [sum_amount_paid] amount_paid,";
            strQuery += " [remarks] remarks";
            strQuery += " FROM [vw_payment]";
            strQuery += " WHERE CONVERT(VARCHAR(10),[payment_date],121) = '" + PCPUB.m_tran_date.ToString("yyyy-MM-dd") + "'";
            strQuery += " ORDER BY [payment_id]";
            sql_conn = new SqlConnection(db_connection_string);
            sql_conn.Open();
            sql_comm.CommandText = strQuery;
            sql_comm.Connection = sql_conn;
            sql_adap.SelectCommand = sql_comm;
            //
            dgvc = new DataGridViewTextBoxColumn();
            dgvc.HeaderText = "Date";
            dgvc.Name = "payment_date";
            dgvc.DataPropertyName = dgvc.Name;
            dgvc.Width = 100;
            dgvc.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dgvc.FillWeight = dgvc.Width;
            dgv_list.Columns.Add(dgvc);
            //
            dgvc = new DataGridViewTextBoxColumn();
            dgvc.HeaderText = "Id";
            dgvc.Name = "payment_id";
            dgvc.DataPropertyName = dgvc.Name;
            dgvc.Width = 100;
            dgvc.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dgvc.FillWeight = dgvc.Width;
            dgv_list.Columns.Add(dgvc);
            //
            dgvc = new DataGridViewTextBoxColumn();
            dgvc.HeaderText = "Vendor Type";
            dgvc.Name = "vendor_type_name";
            dgvc.DataPropertyName = dgvc.Name;
            dgvc.Width = 300;
            dgvc.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dgvc.FillWeight = dgvc.Width;
            dgv_list.Columns.Add(dgvc);
            //
            dgvc = new DataGridViewTextBoxColumn();
            dgvc.HeaderText = "Vendor";
            dgvc.Name = "vendor_name";
            dgvc.DataPropertyName = dgvc.Name;
            dgvc.Width = 300;
            dgvc.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dgvc.FillWeight = dgvc.Width;
            dgv_list.Columns.Add(dgvc);
            //
            dgvc = new DataGridViewTextBoxColumn();
            dgvc.HeaderText = "Amount Paid";
            dgvc.Name = "amount_paid";
            dgvc.DataPropertyName = dgvc.Name;
            dgvc.Width = 150;
            dgvc.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dgvc.FillWeight = dgvc.Width;
            dgv_list.Columns.Add(dgvc);
            //
            dgvc = new DataGridViewTextBoxColumn();
            dgvc.HeaderText = "Remarks";
            dgvc.Name = "remarks";
            dgvc.DataPropertyName = dgvc.Name;
            dgvc.Width = 300;
            dgvc.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dgvc.FillWeight = dgvc.Width;
            dgv_list.Columns.Add(dgvc);
            //
            dt_list.TableName = "payment";
            dt_list.Columns.Add("payment_date");
            dt_list.Columns.Add("payment_id");
            dt_list.Columns.Add("vendor_type_name");
            dt_list.Columns.Add("vendor_name");
            dt_list.Columns.Add("amount_paid");
            dt_list.Columns.Add("remarks");
            //
            ds_list.Tables.Add(dt_list);
            bs_list.DataSource = ds_list;
            bs_list.DataMember = "payment";
            dt_list.Clear();
            sql_adap.Fill(dt_list);
            tsb_print.Enabled = true;
        }

        private void load_FMTR602()
        {
            String strQuery = String.Empty;
            String db_connection_string = PCPUB.m_sqldb_connection.ToString();
            DataGridViewTextBoxColumn dgvc;
            //
            strQuery = String.Empty;
            strQuery += " SELECT CONVERT(VARCHAR(10),[receipt_date],103) receipt_date, receipt_id, vendor_type_name, vendor_name,amount,remarks ";
            strQuery += " FROM [vw_receipt] ";
            strQuery += " WHERE CONVERT(VARCHAR(10),[receipt_date],121) = '" + PCPUB.m_tran_date.ToString("yyyy-MM-dd") + "'";
            strQuery += " ORDER BY [receipt_id]";
            sql_conn = new SqlConnection(db_connection_string);
            sql_conn.Open();
            sql_comm.CommandText = strQuery;
            sql_comm.Connection = sql_conn;
            sql_adap.SelectCommand = sql_comm;
            //
            dgvc = new DataGridViewTextBoxColumn();
            dgvc.HeaderText = "Date";
            dgvc.Name = "receipt_date";
            dgvc.DataPropertyName = dgvc.Name;
            dgvc.Width = 100;
            dgvc.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dgvc.FillWeight = dgvc.Width;
            dgv_list.Columns.Add(dgvc);
            //
            dgvc = new DataGridViewTextBoxColumn();
            dgvc.HeaderText = "Id";
            dgvc.Name = "receipt_id";
            dgvc.DataPropertyName = dgvc.Name;
            dgvc.Width = 100;
            dgvc.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dgvc.FillWeight = dgvc.Width;
            dgv_list.Columns.Add(dgvc);
            //
            dgvc = new DataGridViewTextBoxColumn();
            dgvc.HeaderText = "Vendor Type";
            dgvc.Name = "vendor_type_name";
            dgvc.DataPropertyName = dgvc.Name;
            dgvc.Width = 300;
            dgvc.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dgvc.FillWeight = dgvc.Width;
            dgv_list.Columns.Add(dgvc);
            //
            dgvc = new DataGridViewTextBoxColumn();
            dgvc.HeaderText = "Vendor";
            dgvc.Name = "vendor_name";
            dgvc.DataPropertyName = dgvc.Name;
            dgvc.Width = 300;
            dgvc.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dgvc.FillWeight = dgvc.Width;
            dgv_list.Columns.Add(dgvc);
            //
            dgvc = new DataGridViewTextBoxColumn();
            dgvc.HeaderText = "Amount";
            dgvc.Name = "amount";
            dgvc.DataPropertyName = dgvc.Name;
            dgvc.Width = 150;
            dgvc.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dgvc.FillWeight = dgvc.Width;
            dgv_list.Columns.Add(dgvc);
            //
            dgvc = new DataGridViewTextBoxColumn();
            dgvc.HeaderText = "Remarks";
            dgvc.Name = "remarks";
            dgvc.DataPropertyName = dgvc.Name;
            dgvc.Width = 300;
            dgvc.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dgvc.FillWeight = dgvc.Width;
            dgv_list.Columns.Add(dgvc);
            //
            dt_list.TableName = "receipt";
            dt_list.Columns.Add("receipt_date");
            dt_list.Columns.Add("receipt_id");
            dt_list.Columns.Add("vendor_type_name");
            dt_list.Columns.Add("vendor_name");
            dt_list.Columns.Add("amount");
            dt_list.Columns.Add("remarks");
            //
            ds_list.Tables.Add(dt_list);
            bs_list.DataSource = ds_list;
            bs_list.DataMember = "receipt";
            dt_list.Clear();
            sql_adap.Fill(dt_list);
            tsb_print.Enabled = true;
        }

        private void load_FMTR603()
        {
            String strQuery = String.Empty;
            String db_connection_string = PCPUB.m_sqldb_connection.ToString();
            DataGridViewTextBoxColumn dgvc;
            //
            strQuery = String.Empty;
            strQuery += " SELECT CONVERT(VARCHAR(10),[payment_date],103) payment_date,";
            strQuery += " [payment_id] payment_id,";
            strQuery += " [vendor_type_id] vendor_type_id,";
            strQuery += " [vendor_type_name] vendor_type_name,";
            strQuery += " [vendor_id] vendor_id,";
            strQuery += " [vendor_name] vendor_name,";
            strQuery += " [sum_amount_paid] amount_paid,";
            strQuery += " [remarks] remarks,";
            strQuery += " (SELECT CASE ISNULL([payment_status],'N') WHEN 'N' THEN 'Not Paid' WHEN 'P' THEN 'Paid' WHEN 'M' THEN 'Created' END) payment_status";
            strQuery += " FROM [vw_payment]";
            strQuery += " WHERE CONVERT(VARCHAR(10),[payment_date],121) = '" + PCPUB.m_tran_date.ToString("yyyy-MM-dd") + "'";
            strQuery += " ORDER BY [payment_id]";
            sql_conn = new SqlConnection(db_connection_string);
            sql_conn.Open();
            sql_comm.CommandText = strQuery;
            sql_comm.Connection = sql_conn;
            sql_adap.SelectCommand = sql_comm;
            //
            dgvc = new DataGridViewTextBoxColumn();
            dgvc.HeaderText = "Date";
            dgvc.Name = "payment_date";
            dgvc.DataPropertyName = dgvc.Name;
            dgvc.Width = 100;
            dgvc.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dgvc.FillWeight = dgvc.Width;
            dgv_list.Columns.Add(dgvc);
            //
            dgvc = new DataGridViewTextBoxColumn();
            dgvc.HeaderText = "Id";
            dgvc.Name = "payment_id";
            dgvc.DataPropertyName = dgvc.Name;
            dgvc.Width = 100;
            dgvc.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dgvc.FillWeight = dgvc.Width;
            dgv_list.Columns.Add(dgvc);
            //
            dgvc = new DataGridViewTextBoxColumn();
            dgvc.HeaderText = "Vendor Type";
            dgvc.Name = "vendor_type_name";
            dgvc.DataPropertyName = dgvc.Name;
            dgvc.Width = 300;
            dgvc.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dgvc.FillWeight = dgvc.Width;
            dgv_list.Columns.Add(dgvc);
            //
            dgvc = new DataGridViewTextBoxColumn();
            dgvc.HeaderText = "Vendor";
            dgvc.Name = "vendor_name";
            dgvc.DataPropertyName = dgvc.Name;
            dgvc.Width = 300;
            dgvc.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dgvc.FillWeight = dgvc.Width;
            dgv_list.Columns.Add(dgvc);
            //
            dgvc = new DataGridViewTextBoxColumn();
            dgvc.HeaderText = "Amount Paid";
            dgvc.Name = "amount_paid";
            dgvc.DataPropertyName = dgvc.Name;
            dgvc.Width = 150;
            dgvc.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dgvc.FillWeight = dgvc.Width;
            dgv_list.Columns.Add(dgvc);
            //
            dgvc = new DataGridViewTextBoxColumn();
            dgvc.HeaderText = "Remarks";
            dgvc.Name = "remarks";
            dgvc.DataPropertyName = dgvc.Name;
            dgvc.Width = 300;
            dgvc.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dgvc.FillWeight = dgvc.Width;
            dgv_list.Columns.Add(dgvc);
            //
            dgvc = new DataGridViewTextBoxColumn();
            dgvc.HeaderText = "Status";
            dgvc.Name = "payment_status";
            dgvc.DataPropertyName = dgvc.Name;
            dgvc.Width = 100;
            dgvc.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dgvc.FillWeight = dgvc.Width;
            dgv_list.Columns.Add(dgvc);
            //
            dt_list.TableName = "payment";
            dt_list.Columns.Add("payment_date");
            dt_list.Columns.Add("payment_id");
            dt_list.Columns.Add("vendor_type_name");
            dt_list.Columns.Add("vendor_name");
            dt_list.Columns.Add("amount_paid");
            dt_list.Columns.Add("remarks");
            dt_list.Columns.Add("payment_status");
            //
            ds_list.Tables.Add(dt_list);
            bs_list.DataSource = ds_list;
            bs_list.DataMember = "payment";
            dt_list.Clear();
            sql_adap.Fill(dt_list);
            tsb_print.Enabled = true;
        }

        private void dgv_list_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {

        }

    }

}
